<template>
	<uni-card :is-shadow="false">
		<text class="uni-h1">Mapbox 插件</text>
	</uni-card>
	<uni-card :is-shadow="false">
		<uni-section title="测试" type="line" padding>
			<button @click="requestRoutes" type="primary" class="mt-1 mx-1">测试看log</button>
	
		</uni-section>
	</uni-card>
</template>

<script>
	export default {
		data() {
			return {
				qsSdk: null,
				TAG: 'TestModule',
			}
		},
		onLoad() {
			this.qsSdk = uni.requireNativePlugin('Huo15-Mapbox')
			this.qsSdk.checkLocationPermission(res=>{
				this.log(res)
				uni.showToast({
					title:"申请权限是否成功："+res.result,
					icon:'none'
				})
			})
		},
		methods: {
			log(msg) {
				console.log(this.TAG + ": ", msg)
			},
			requestRoutes(){
				//116.477283,39.972465
				//116.237543,39.941051
				this.qsSdk.requestRoutes({
					coordinatesList: [{
							latitude: 39.972465,
							longitude: 116.477283
						},
						{
							latitude: 39.941051,
							longitude: 116.237543
						}
					], //[起点，途经点(可选)，终点]
					steps: true,
					bannerInstructions: true,
					voiceInstructions: true,
					profile: "cycling" //driving-traffic driving walking cycling
				}, (res)=> {
					this.log(res.data)
					if (res.type == "onRoutesReady") { //路径规划成功
				// 		naviView.startRoutePreview();
				// 		if (uni.getStorageSync('closebtn') == 1) {
				// 			that.NavStrat = uni.getSubNVueById('NavStrat')
				// 			that.NavStrat.show('slide-in-bottom', 250);
				// 			uni.$emit('NavStrat', {
				// 				break: 1,
				// 				list: res.data
				// 			});
				// 			setTimeout(() => {
				// 				self.startTripSession();
				// 			}, 1000)
				// 		} else {
				
				// 		}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #eee;
	}

	.mt-1 {
		margin-top: 10rpx;
	}

	.mx-1 {
		margin-left: 10rpx;
		margin-right: 10rpx;
	}
</style>